#ifndef SINGLETON_H
#define SINGLETON_H
#include<memory>
#include<string>
#include<mutex>
#include <QString>
class Singleton
{
public:
    static std::shared_ptr<Singleton> GetInstance();
    // 删除复制构造函数和赋值运算符，防止复制实例
    Singleton(const Singleton&) = delete;
    Singleton& operator=(const Singleton&) = delete;

    bool readConfigFile(QString& username, QString& password);
    bool writeConfigFile(const QString& username, const QString& password);
    bool deleteConfigFile();
    bool fileIsExists() const;
    void clearFile();
private:
    Singleton();
    ~Singleton();

    static std::shared_ptr<Singleton> mInstance;
    static std::once_flag mflag;
    QString mFileName;
};

#endif // SINGLETON_H
